package test04;

import java.util.ArrayList;

public class OperateImpl2 implements Impl{
    @Override
    public void showAll(ArrayList<Student> students) {
        int count1 = 0;
        int count2 = 0;
        for (int i = 0; i < students.size(); i++) {
            Student s = students.get(i);
            System.out.println(s.toString());
            if(s.getSex().equals("男"))
                count1++;
            else
                count2++;
        }
        System.out.println("男生人数：" + count1);
        System.out.println("女生人数：" + count2);
    }

    @Override
    public void showEverage(ArrayList<Student> students) {
        double sum = 0;
        double min = students.get(0).getScore();
        double max = students.get(0).getScore();
        for (int i = 0; i < students.size(); i++) {
            Student s = students.get(i);
            sum += s.getScore();
            if (s.getScore() > max) max = s.getScore();
            if (s.getScore() < min) min = s.getScore();
        }
        System.out.println("平均分是："+(sum - min - max) / (students.size() - 2));
        System.out.println("最大：" + max);
        System.out.println("最小：" + min);
    }
}
